<template>
  <div class="ly-wrap">
    <div class="sub-title">当前小区：{{name}}</div>
    <form v-model="info">
      <yd-cell-group title="投诉建议内容/描述">
        <yd-cell-item>
          <yd-textarea slot="right" v-model="info.content" placeholder="请输入投诉建议内容/描述" maxlength="100"></yd-textarea>
        </yd-cell-item>
      </yd-cell-group>
      <yd-cell-group title="联系人电话">
        <yd-cell-item>
          <yd-input slot="right" v-model="info.number" placeholder="请输入联系人电话"></yd-input>
        </yd-cell-item>
      </yd-cell-group>
    </form>
    <yd-button style="width: 88%;margin: 0.3rem auto;" size="large" type="primary" @click.native="upRepairInfo()">
      提交
    </yd-button>
  </div>

</template>

<script>
  import http from "../../http";
  import storage from "../../store/storage.js";

  export default {

    data() {
      return {
        name: "",
        housingId: '',
        info: {
          content: '',
          number: '',
        },
        repairList: [],
        loading: false,

      };
    },
    created: function () {
      this.init();
    },
    methods: {
      fn(label, key) {

      },
      itemClick(key) {
        this.tab2 = key;
      },

      init: function () {
        this.name = storage.getObj("housingId").name;
        this.housingId = storage.getObj("housingId").id;
      },

      upRepairInfo: function () {

        if (this.info.content == '') {
          this.$dialog.toast({
            mes: "请输入投诉建议内容/描述",
            timeout: 2000
          });
        } else if (this.info.number == '') {
          this.$dialog.toast({
            mes: "请输入联系电话",
            timeout: 2000
          });
        } else {
          const parmas = {
            typeInt: 2,
            housingId: this.housingId,
            content: this.info.content,
            telphone: this.info.number,
          };
          http.post("/communityApps/reportms/addReportms", parmas).then(res => {
            if (res.data.code == 20000) {
              this.$dialog.toast({
                mes: "提交成功！",
                timeout: 500,
                callback: () => {
                  this.$router.push({path: '/'})
                }
              });

            } else {
              this.$dialog.toast({
                mes: res.data.message,
                timeout: 2000
              });
            }
          });
        }
      },

    }
  }
  ;
</script>


<style scoped lang="scss">


  .sub-title {
    color: #666;
    font-size: .28rem;
    line-height: 0.4rem;
    padding: .2rem .24rem .1rem;
  }

  .clear {
    clear: both;
  }


</style>
